#include "enemy.h"

#include "terrain.h"
#include "vector.h"

CEnemy::CEnemy() 
{
	isDead = false;     // enemy starts off alive
	velocity = CVector(0.0, 0.0, 0.0); // speed of enemy
	runSpeed = velocity.z;
	SetState(MODEL_IDLE);    // idle state
	canChangeAction = true;
	direction = 0.0f;        // point north
	player = NULL;
}

CEnemy::~CEnemy() {}


void CEnemy::OnCollision(CObject *collisionObject)
{
	// if this enemy collides with another enemy
	if (typeid(*collisionObject) == typeid(CEnemy))
	{
		modelState = MODEL_IDLE;
		velocity = CVector(0.0, 0.0, 0.0);
	}
	// if this enemy collides with the terrain (always)
	else if (typeid(*collisionObject) == typeid(CTerrain))
	{
		position.y = ((CTerrain*)collisionObject)->GetHeight(position.x, position.z) + size;
	}
}

void CEnemy::ProcessAI() {
	OnProcessAI();
}

void CEnemy::SetPlayer(CPlayer *p) {
	player = p;
}